<template>
	<view class="index">
		<!-- #ifdef H5-->
		<!-- #endif-->
		<!-- #ifdef  MP-->
		<!-- #endif-->
        <view class="index">
            <view class="index_banner">
                <image src="/static/images/index/banner.png"  mode='aspectFill'/>
            </view>
            <view class="index_cnt">
                <view class="index_cnt_img" @click.native="handelClick" data-text="department">
                    <image src="/static/images/index/img1.png"  mode='aspectFill'/>
                </view>
                <view class="index_cnt_img" @click.native="handelClick" data-text="advisory">
                    <image src="/static/images/index/img2.png"  mode='aspectFill'/>
                </view>
            </view>
        </view>
        <!-- #ifdef APP-PLUS-->
            <button type="primary" @click="share">分享</button>
        <!-- #endif-->
        <i class="iconfont icon-close-b"></i>
	</view>
</template>

<script>
	import login from "@/h5components/login/index.vue"
    import API from '@/utils/api.js'
	export default {
		data() {
			return {
			}
		},
		components:{
			login
		},
		onLoad() {
           //  console.log(getApp().globalData.name,'说但事实上') 
            var res = global.isLogin();
            if(!res){
                uni.showModal({
                    title:"提醒",
                    content:"请先登录",
                    success:function() {
                        wx.navigateTo({
                                url: "/pages/login"
                            })
                    }
                })
            }
           
             // 通过uni.login()接口获取小程序用户的code值
            // uni.login({
            //     success: function (el) {
            //         let params = {
            //             code: el.code,
            //             hospitalId: "350101",
            //             openid: "xxxx"
            //         };
            //         //获取openid sessinkey
            //         API.getOpenId(params).then(res => {
            //             console.log(res)
            //             if(res.success ===true){
            //                 uni.setStorageSync('openid', res.entity.openid);
            //                 uni.setStorageSync('patientUserId', res.entity.patientUserId);
            //                 uni.setStorageSync('hospitalId', params.hospitalId)
            //             }
            //         })
            //     }
            // });
		},
		methods: {
            share:function(){
                
            },
			//跳转页面
            handelClick(e){
                uni.chooseImage({
                    count: 6, //默认9
                    sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图，默认二者都有
                    sourceType: ['album'], //从相册选择
                    success: function (res) {
                        console.log(JSON.stringify(res.tempFilePaths));
                    }
                });
                // let text = e.currentTarget.dataset.text;
                // if (text ==="department"){
                //     wx.navigateTo({
                //         url: "/pages/consultation/department/index"
                //     })
                // }else{
                //     wx.navigateTo({
                //         url: "/pages/consultation/advisoryRecord/index"
                //     })
                // }
            }
		},
        onShareAppMessage:function(){
            return {
                title:"朋友们",
                path:"pages/index/index"
            }
        }
	
    }
</script>

<style scoped lang="scss">
	.index,page,body,html{
	    background: #fff;
	}
	.index_banner{
	    width: 750rpx;
	    height: 272rpx;
	    margin-bottom: 45rpx;
	}
	.index_cnt{
	    padding: 30rpx 8rpx;
	}
	.index_cnt_img {
	    width: 734rpx;
	    height: 261rpx;
	    margin-bottom: 30rpx;
	}
</style>
